import { PostRes } from "~/rest";
import { MediaGateway, MediaGroupGateway } from "./dto.media";
import { Media, MediaGroup } from "./schema.media";
import { ENUM_MEDIA_PREFIX } from "./core.define";
import { PageResult } from "~/search";

export const MediaRpcGetHighestGroupSyncPath = `${MediaGroupGateway.path}/getHighestGroupSync`;
export const MediaRpcFindOnePath = `${MediaGateway.path}/findOne`;
export type findOneMediaRpcDto = { id: Media["id"] };

export const MediaRpcFindManyPath = `${MediaGateway.path}/findMany`;
export type findManyMediaRpcDto = { ids: Media["id"][] };

export const MediaRpcInsertOnePath = `${MediaGateway.path}/insertOne`;
export type insertOneMediaRpcDto = { prefix: ENUM_MEDIA_PREFIX; fileName: string; suffix: string; base64: string };

export interface MediaRpcInterfaceWithDerive<T> {
  getHighestGroupSync(dto: T): Promise<{ group: MediaGroup }>;

  findOne(dto: T & findOneMediaRpcDto): Promise<Media>;
  findMany(dto: T & findManyMediaRpcDto): Promise<PageResult<Media>>;
  insertOne(dto: T & insertOneMediaRpcDto): Promise<PostRes<Media>>;
}
